<template>
	<view class="withdraw_wrad">
		<view class="withdraw_tabs">
			<u-tabs v-model="activeTab" :scroll="false" :tabs="tabs" @change="tabChange" :lineScale="2">
			</u-tabs>
		</view>
		<scroll-view show-scrollbar="false" class="withdraw_list" scroll-y @scrolltolower="scrollLoading()">
			<view class="ward" v-for="(item, index) in records" :key="index">
				<view class="amount">
					<view>提现-{{ item.withdrawWay }}</view>
					<view style="color:#006DFF">+￥{{ item.amount }}</view>
				</view>
				<view>
					<view class="orders">
						<view>
							<image
								src="https://res.jiuzhang-cloud.com/jzy-oss/upload/image/dti-hospital/agencies/orders_number.png">
							</image>
							<view>订单号</view>
						</view>
						<view>{{ item.orderCode }}
						</view>
					</view>
					<view class="orders">
						<view>
							<image
								src="https://res.jiuzhang-cloud.com/jzy-oss/upload/image/dti-hospital/agencies/orders_time.png">
							</image>
							<view>申请时间</view>
						</view>
						<view>{{ item.createdTime }}
						</view>
					</view>
					<view class="orders">
						<view>
							<image
								src="https://res.jiuzhang-cloud.com/jzy-oss/upload/image/dti-hospital/agencies/withdraw_state.png">
							</image>
							<view>申请状态</view>
						</view>
						<view
							:style="item.status == 1 ? 'color:#FF9660' : item.status == 2 ? 'color:#24E104' : 'color:#FC4E4C'">
							{{ item.statusName }}</view>
					</view>
				</view>
			</view>
			<u-empty-state v-if="records.length == 0" value="暂无相关记录"></u-empty-state>
		</scroll-view>

	</view>
</template>

<script>
export default {
	data() {
		return {
			busType: '',
			tabs: ['全部', '待审核', '已通过', '已驳回'],
			status: ['', 'auditing', 'pass', 'reject'],  //tabs参数集合
			activeTab: 0,
			records: [],
			pageNo: 1,
			total: 0
		}
	},
	onLoad(option) {
		this.busType = option.busType  //业务场景
		this.activeTab = option.activeTab || 0
	},
	onShow() {
		this.records = []
		this.pageNo = 1
		this.getWithdrawLise()
	},
	methods: {
		tabChange(e) {  //选项切换
			this.activeTab = e
			// 重置页码和内容
			this.records = []
			this.pageNo = 1
			this.getWithdrawLise()
		},
		getWithdrawLise() {
			this.$api.getWithdrawLise({
				params: {
					pageSize: 10,
					pageNo: this.pageNo,
					status: this.status[this.activeTab],
					busType: this.busType
				}
			}).then(e => {
				// console.log(e);
				let { code, result: { records, total } } = e
				if (code == 200) {
					this.total = total
					this.records.push.apply(this.records, records);
				} else {
					uni.showToast({
						title: e.message,
						icon: 'none'
					});
				}
			})
		},
		// 滚动加载 - 触底
		scrollLoading() {
			// console.log('触底啦');
			if (this.pageNo * 10 < this.total) {
				this.pageNo++
				this.getWithdrawLise()
			}

		}
	}
}
</script>

<style lang="less">
@import './withdrawList.less';
</style>
